package com.my.jli.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName JsonUtil
 * @Description
 * @Author MaYu
 * @Date 2022/5/4 17:39
 * @Version 1.0
 **/
public class JsonUtil {
    public static Map<Integer, String> getAnswerMap(String jsonStr){
        Map<Integer, String> answerMap = new HashMap<>();
        if(jsonStr != null && !"".equals(jsonStr)){
            String[] split = jsonStr.replace("{", "").replace("}", "").split(",");
            for (String s : split) {
                Integer id = Integer.valueOf(s.split(":")[0].replace("\"", ""));
                String answer = s.split(":")[1].replace("\"", "");
                answerMap.put(id, answer);
            }
            return answerMap;
        }else{
            return null;
        }
    }
}
